#include "Time.h"

// Constructor
Time::Time(void)
{
	prevTime = 0.0f;
	totalFrames = 0;
	fpsTimer = 0.0f;
}

// Destructor
Time::~Time(void)
{
}

// GetInstance
//	- RETURNS a constant reference to the Time singleton.
Time& Time::GetInstance(void)
{
	static Time time;
	return time;
}

void Time::Update( void )
{
	float TimeNow = (float)GetTickCount();
	deltaTime = ( TimeNow - prevTime ) / 1000.0f;
	prevTime = TimeNow;

	if( deltaTime > .1f )
		deltaTime = .1f;

	++totalFrames;
	fpsTimer += deltaTime;
	if(fpsTimer >= 1.0f)
	{
		fps = totalFrames;
		totalFrames = 0;
		fpsTimer = 0.0f;
	}
}
